package database;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Manu {
    ArrayList arrayList = new ArrayList();



    Room jjxyroom;
    Room[] room = new Room[100];
    int comsumer_select;
    JdbcRoom jdroom;

    int i=0;
    Scanner scan = new Scanner(System.in);//输入要求
    public Manu(int xx,Room room){
        if(i>9999){
            System.out.println("寝室已满，不可添加数据");
        }



//        while(true){
//            System.out.println("********************************");
//            System.out.println("欢迎来到九江学院寝室管理系统");
//            System.out.println("请选择您要办理的业务");
//            System.out.println("1.寝室查询  2.寝室长查询  3.寝室卫生排名表");
//            System.out.println("4.添加寝室  5.修改寝室  6.删除寝室");
//            System.out.println("7.查询整个学校寝室数据  8.退出");
//            System.out.println("********************************");
//            System.out.print("请开始你的输入：");
        select_switch(xx,room);



        }
    //}
    public void select_switch(int userselect,Room room1){
        switch (userselect){
            case 8:
                System.out.println("欢迎下次使用");System.exit(0);break;
            case 1:FindRoom(room1);break;
            case 2:FindStudent(room1);break;
            case 3:AccessSanitateList();break;
            case 4:InsertRoom(room1);break;
            case 5:ChangeStudent(room1);break;
            case 6:DeleteRoom(room1);break;
            case 7:FindAllRoom();break;
            default:
                System.out.println("你的选项不在我们的服务范围内");
                System.out.println();
        }
    }
    public void FindRoom(Room room1){
        int room_number = room1.getRnum();
        arrayList.add(room_number);
        jdroom = new JdbcRoom(1,arrayList);
        jjxyroom=jdroom.getRoom();
        arrayList.clear();
    }
    public void FindStudent(Room room1){
        String StuName = room1.getStudentname();
        arrayList.add(StuName);

        jdroom = new JdbcRoom(2,arrayList);
        setJjxyroom(jdroom.getRoom());
        arrayList.clear();
    }
    public void AccessSanitateList(){

        jdroom = new JdbcRoom(3,arrayList);
        arrayList=jdroom.getRName();
    }
    public void InsertRoom(Room room1){
//        System.out.println("请按要求输入数据，不可缺少");
//        System.out.print("寝室昵称：");
//        String rname = scan.next();
//        System.out.print("寝室号码：");
//        int rnumber = scan.nextInt();
//        System.out.print("寝室人数：");
//        int rcount = scan.nextInt();
//        System.out.print("男寝or女寝：");
//        String rsex = scan.next();
//        System.out.print("寝室卫生：");
//        String rsanitate = scan.next();
//        System.out.print("寝室获奖：");
//        String raward = scan.next();
//        System.out.print("寝室长名字：");
//        String rstuname = scan.next();
        jjxyroom = room1;
        room[i] = jjxyroom;
        i++;

        arrayList  = jjxyroom.getList();
        jdroom = new JdbcRoom(4,arrayList);

    }
    public void ChangeStudent(Room room1){
        String name = room1.getName();
        arrayList.add(name);
        int number = room1.getRnum();
        arrayList.add(number);
        int count = room1.getCount();
        arrayList.add(count);
        String sex = room1.getSex();
        arrayList.add(sex);
        String sanitate = room1.getSanitate();
        arrayList.add(sanitate);
        String award = room1.getAward();
        arrayList.add(award);
        String studentname = room1.getStudentname();
        arrayList.add(studentname);
        jdroom = new JdbcRoom(5,arrayList);
        arrayList.clear();
    }
    public void DeleteRoom(Room room1){

        int number = room1.getRnum();
        arrayList.add(number);
        jdroom = new JdbcRoom(6,arrayList);
        arrayList.clear();
    }
    public void FindAllRoom(){

        jdroom = new JdbcRoom(7,arrayList);
        arrayList = new ArrayList();
        arrayList = jdroom.getRName();

    }
    public Room getJjxyroom() {
        return jjxyroom;
    }

    public void setJjxyroom(Room jjxyroom) {
        this.jjxyroom = jjxyroom;
    }
    public ArrayList getArrayList(){
        return arrayList;
    }
}
